//
// Created by xzl01 on 2022/4/15.
//

#ifndef CALCUMAID_XCALENDAR_H
#define CALCUMAID_XCALENDAR_H
#include <QWidget>
#include <QDate>
#include <QtUiPlugin/QDesignerExportWidget>
#include <QPushButton>
#include <QColor>
#include <QProxyStyle>
#include <QCalendarWidget>
#include <QLocale>
#include <QTextCharFormat>
#include <QSizePolicy>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QPainter>

class XCalendar:public QCalendarWidget
{
Q_OBJECT
	//Q_PROPERTY(QColor bgColor READ getBgColor WRITE setBgColor)//定义一个宏

public:
	 explicit XCalendar(QWidget *parent= nullptr);//构造函数
	~XCalendar();//析构函数

private:
	void initControl();
	void initTopWidget();
	void paintCell(QPainter *painter,const QRect &rect,const QDate &date)const;//画选装的单元
	void initBottomWidget();
	void setDataLabelText(int year, int mounth);


signals:
	void signalSetCalendarTime(const QDate& data);
private slots:
	void onBtnClicked();

protected:
	void paintCell(QPainter *painter,const QRect &rect,QDate &date)const;

private:
	QPushButton* leftYearBtn;//年 左侧按钮
	QPushButton* rightYearBtn;

	QPushButton* leftMonthBtn;
	QPushButton* rightMonthBtn;

	QPushButton* ensureBtn;//确认按键
	QPushButton* todayBtn;//今日按键
	QLabel* dataLabel;






};

class QCustomStyle :public QProxyStyle
{
public:
	QCustomStyle(QWidget *parent);
private:
	void drawPrimitive();
};

#endif //CALCUMAID_XCALENDAR_H
